package com.dhcc.core.modules.system.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.plugins.Page;
import com.dhcc.core.framework.base.service.impl.BaseServiceImpl;
import com.dhcc.core.framework.constant.state.PositionType;
import com.dhcc.core.framework.result.node.ZTreeNode;
import com.dhcc.core.modules.system.dao.PositionMapper;
import com.dhcc.core.modules.system.entity.Position;
import com.dhcc.core.modules.system.service.IPositionService;

/**
 * 职务表数据服务层接口
 * 
 * @ClassName: PositionServiceImpl
 * @Description: TODO
 * @author mk
 * @date 2018-08-28 08:52:01
 */
@Service("positionService")
public class PositionServiceImpl extends BaseServiceImpl<PositionMapper, Position> implements IPositionService {

    @Override
    public List<Position> page(Page<Position> page, Map<String, Object> map) {
        return this.baseMapper.page(page, map);
    }
    
    @Override
    public List<Position> list(Map<String, Object> map) {
        return this.baseMapper.list(map);
    }

	@Override
	public Boolean codevalidate(String code) {
		Position position = this.baseMapper.codevalidate(code);
		Boolean msg = true;
		if(position != null){
			msg = false;
		}
		return msg;
	}

    @Override
    public List<ZTreeNode> tree() {
        List<ZTreeNode> tree = this.baseMapper.tree();
        for (PositionType pt : PositionType.values()) {
            tree.add(ZTreeNode.createNode(pt.getCode()+0l,999l, pt.getName()));
        }
        return tree;
    }

    @Override
    public Position selectByCode(String code) {
        Position entity = new Position();
        entity.setCode(code);
        return this.baseMapper.selectOne(entity);
    }

}